<?php
/**
 * Created by PhpStorm.
 * User: cc
 * Date: 2024/10/14
 * Time: 上午11:01
 */

namespace App\Models\CacheModel;

use App\Models\Api\BaseCache;
use AstroTool\Cache\CacheManage;

class AppUserForbidDeviceRecord extends BaseCache
{
    protected $table = 'wechat_backup_07_18_14_43_00.app_user_forbid_device_record';
    protected $cacheModel = 'user.forbid_device_info';

    /**
     * 获取设备号封号信息
     * @param $deviceId
     * @param array $field
     * @return array|bool|mixed|string
     * @throws \Exception
     */
    public function getUserForbidDeviceInfo($deviceId, array $field = [])
    {

        return CacheManage::getInstance()->setCacheConfig($this->cacheModel, $deviceId)->getDataAndSet(function () use ($deviceId)
        {
            try
            {
                return $this->where(['device_id' => $deviceId])->field('status,create_time,device_id')->order('id desc')->findOrFail()->toArray();
            }
            catch (\Exception $e)
            {
                return [];
            }
        }, $field);
    }
}
